import gameConfig, {JumpMiniGameConfig} from "../../engines/configs/gameConfig";
import cellMiniGameJump from "../public/cellMiniGameJump";

const {ccclass, property} = cc._decorator;

@ccclass
export default class cellLayerMiniGameJump extends cc.Component {

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start() {
        this.onShowMiniJumpCellList();
    }

    //设置位置
    setPosition(...position: cc.Vec2[]) {
        for (let i = 0; i < position.length && i < this.node.childrenCount; i++) {
            this.node.children[i].setPosition(position[i]);
        }
    }

    protected onShowMiniJumpCellList() {
        let ary = gameConfig.MINI_GAME_JUMP_CELL_LIST;
        //
        for (let i = 0; i < this.node.childrenCount; i++) {
            if (ary[i] == null) {
                this.node.children[i].active = false;
                continue;
            }
            this.node.children[i].active = true;
            //
            this.showCellData(this.node.children[i], ary[i]);
        }
    }

    protected showCellData(node: cc.Node, data: JumpMiniGameConfig) {
        node.getComponent(cellMiniGameJump).setData(data);
    }

    // update (dt) {}
}
